
<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#--引入一个模板-->
    <#include "../common/header.ftl">

</head>

<script>
    $(function () {


        //修改news状态
        $(".changeStateBtn").click(function () {
            var state = $(this).data("state");
            var id = $(this).data("id");

            $.get("/news/changeState.do",{state:state,id:id},function (data) {
                if (data.success) {
                    window.location.href = "/news/releaseList.do";
                }else {
                    $.messager.alert("提示",data.msg);
                }
            })
        })

        //获取文章内容
        $(".showContent").click(function () {
            var id = $(this).data("id");
            $.get("/news/getNewsContent.do",{newsId:id},function (data) {
                console.log(data);

                $("#showContentModal .modal-body").html(data.content)
                $("#showContentModal").modal("show");
            })
        })

    })
</script>

<style>
    #showContentModal img{
        width: 100%;
    }
    #showContentModal .modal-body{
        max-height: 600px;
        overflow-y: auto;
    }
</style>

<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
            <#--声明变量-->
            <#assign menu="news">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">待发布日报管理 </h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/news/list.do" method="post">
                <input type="hidden" id="currentPage" name="currentPage" value="1">
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入标题">
                </div>
                <button id="btn_query" class="btn btn-info">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>

            <table class="table table-striped table-hover" >
                <tr>
                    <th>标题</th>
                    <th>概要</th>
                    <th>封面</th>
                    <th>创建时间</th>
                    <th>状态</th>
                    <th>操作</th>

                </tr>
                <#--freemarker中的遍历数组或集合的指令-->
                <#list result.list as entity>
                    <tr>
                        <td>${(entity.title)!}</td>
                        <td>${(entity.summary)!}</td>
                        <td><img src="${(entity.coverUrl)!}" width="30px"></td>
                        <td>${(entity.createTime?string("yyyy-MM-dd"))!}</td>
                        <td>${(entity.stateDisplay)!}</td>
                        <td>
                            <a href="javascript:;" class="btn changeStateBtn" data-state="3" data-id="${entity.id}">发布</a>
                            <a href="javascript:;" class="btn showContent" data-id="${entity.id}">查看文章</a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#--引入分页插件-->
            <#include "../common/page.ftl">
        </div>
    </div>
</div>

<!-- 模态框 -->
<div class="modal fade" id="showContentModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">查看文章内容</h4>
            </div>

            <div class="modal-body">

            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

</body>
</html>